package com.demonzym.framework.net.http;

import android.util.Log;

import com.demonzym.framework.net.task.AbstractHttpTask;

public class HttpManager {
	private static HttpManager mInstance;
	protected static HttpManager getInstance(){
		if(mInstance == null){
			mInstance = new HttpManager();
		}
		return mInstance;
	}

	public static void pushHttp(HttpRequest hr){
		hr.setHttpCallBack(HttpListener.getInstance());
		HttpEngine.getInstance().addAysnRequest(hr);
	}
	
	protected static enum HTTP_RESPONSE_TYPE{
		TYPE_ERROR,
		TYPE_SUCCESS,
		TYPE_DOWNLOAD_PROCESS,
		TYPE_UPLOAD_PROCESS,
	};
	protected static void onGetHttpResponse(HTTP_RESPONSE_TYPE type, HttpResponse hr){
		switch(type){
		case TYPE_ERROR:
			AbstractHttpTask.dispatchError(hr);
			break;
		case TYPE_SUCCESS:
			AbstractHttpTask.dispatchSuccess(hr);
			break;
		case TYPE_DOWNLOAD_PROCESS:
			break;
		case TYPE_UPLOAD_PROCESS:
			AbstractHttpTask.dispatchUploadProcess(hr);
			break;
		}
	}
}
